<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>电影列表案例</title>
  </head>
  <body>
    <div id="root"></div>
  </body>

  <script src="/lib/react.js"></script>
  <script src="/lib/react-dom.js"></script>
  <script src="/lib/babel.js"></script>

  <script type="text/babel">
    class App extends React.Component {
      constructor() {
        super();
        this.state = {
          movies: [
            "星际创越",
            "流浪地球",
            "复仇者联盟",
            "喜羊羊与灰太狼",
          ],
        };
      }

      // 实例方法

      // 渲染函数
      render() {
        const { movies } = this.state
        return (
          <div>
            <h1>电影列表</h1>
            <ul>
              {movies.map((item) => (
                <li key={item}>{item}</li>
              ))}
            </ul>
          </div>
        );
      }
    }

    const rootEl = document.querySelector("#root");
    const root = ReactDOM.createRoot(rootEl);

    root.render(<App />);
  </script>
</html>
